<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #one{
            width: 100px;
        }
        #two{
            width: 100px;
        }
    </style>
</head>
<body>
    <div>
        <input type="text" id="one">
        vs
        <input type="text" id="two">
        <input type="button" value="最大的数是">
        <span>?</span>
    </div>
</body>
<script>
    window.onload = function(){
        var inp = document.getElementsByTagName("input")
        var sp = document.getElementsByTagName("span")[0]
        for(var i = 0 ; i < inp.length-1;i++){
            inp[i].onkeyup = function(){
                this.value = this.value.replace(/[^\d]/,"")
            }

            function match(){
                var m = 0
                m = parseInt(inp[0].value) >= parseInt(inp[1].value) ? parseInt(inp[0].value) : parseInt(inp[1].value)
                return m
            }
            inp[2].onclick = function(){
                sp.innerHTML = match()
            }
        }
    }
</script>
</html>